<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>区别</title>
</head>

<body>

    <div></div>

    <div></div>

    <script>
        //innertext和innerhtml区别
        var div = document.getElementsByTagName('div');
        //innertext不识别html标签 
        div[0].innerText = '<h1>今天是2020</h1>';
        //innerHTML识别标签
        div[1].innerHTML = '<h1>今天是2020</h1>';
    </script>
</body>

</html>